{% extends "base.html" %}

{% block content %}
<div id="topics">
<h2>Add / Edit Discussion</h2>
<br/>

    <div id="entryform">
          <form action="/editdiscussion" method="post" onsubmit="return validate_postdiscussion(this)">
            <fieldset>
            <label>Title:</label>
            <input class="textbox" name="title" value="{{ discussion.title }}"><br>

            <label>Description:</label>
            <textarea name="description" rows="4">{{ discussion.description }}</textarea><br>
            <label>Image URL:</label>
            <input class="textbox" name="imagelink"  value="{% if description.imagelink %}{{ description.imagelink }}{% endif %}"><br>
            {% if description.imagelink %}
            <label>Image:</label>
            <img src="{{ description.imagelink }}"><br>
            {% endif %}
            <label>Discussion Type:</label>
                <select class="listbox" name="type">
                {% for navdiscussiontype in navdiscussiontypes %}
                    <option value="{{ navdiscussiontype }}" {% ifequal discussion.type navdiscussiontype %}selected="selected"{% endifequal %}>{{ navdiscussiontype }}</option>
                {% endfor %}
                </select><br>
            <label>Enabled?:</label>
            <input name="enabled" type="checkbox" {% if discussion.enabled %}checked="checked"{% endif %}><br>
            <label></label>
            <input type="submit" name="action" value="Save Discussion">{% if discussion.key %}<input type="submit" name="action" value="Delete" onclick="return confirm('Are you sure you want to permanently delete this Discussion?');"/>{% endif %}
            <input type="hidden" name="discussionkey" value="{{ discussion.key }}">
            <br>
            </fieldset>
          </form>
    </div>
</div>
{% endblock %}